package com.xmy.cultivate.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xmy.cultivate.entity.*;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xmy.cultivate.entity.views.ArrivalRate;
import com.xmy.cultivate.entity.views.StudentClassLogRep;
import com.xmy.cultivate.entity.views.face.FaceGetScheduling;
import com.xmy.cultivate.enums.ReachTypeEnum;
import com.xmy.cultivate.enums.StatusRecordEnum;
import com.xmy.cultivate.respons.ClassesNum;
import com.xmy.cultivate.util.Result;
import org.apache.ibatis.annotations.Param;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 记止课 服务类
 * </p>
 *
 * @author baomidou
 * @since 2022-08-10
 */
public interface IRecordCourseService extends IService<RecordCourse> {

    public abstract boolean batchAdd(CourseSchedulingDetail courseSchedulingDetail);

    @Transactional
    Boolean resetRecordConsume(RecordCourse recordCourse);

    @Transactional
    boolean recordActionRepair(RecordCourse recordCourseParam);

    /**
     * 按排补课id
     * @param repairCourseId
     * @return
     */
    @Transactional
    boolean repairBuckleMoney(Long repairCourseId);

    /**
     * 大于15次课的，扣除补课金额
     * @param recordCourseId
     * @param byRecordId
     * @return
     */
    @Transactional
    boolean greaterBuckleMoney(Long recordCourseId, Long byRecordId);

    Long addForSchedulingId(Long courseSchedulingDetailId, Long studentId, String studentName, Integer type, Integer courseType, ReachTypeEnum reachTypeEnum, Long siginInTeacherId, LocalDateTime dateTimeNow,Integer signType,String schoolSiteId);

    public IPage<RecordCourse> recordGradeLog(IPage<?> page , QueryWrapper queryWrapper);

    public List<RecordCourse> getlist(Long schedulingDetailId);

    public abstract IPage<StudentClassLogRep> studentClassLog(IPage<RecordCourse> page, Wrapper wrapper);

    public abstract Integer getSolidCount(Long schedulingDetailId,Integer status);

    public abstract Boolean deleteForId(Long id);

    public abstract IPage<RecordCourse> hourStatistics(IPage<?> page , QueryWrapper queryWrapper);

    public abstract IPage<RecordCourse> hourStudentStatistics(IPage<?> page,QueryWrapper queryWrapper);

    public abstract boolean leaveArrive(Long recordCourseId);

    public abstract boolean lackRepairArrive(Long lackCourseLogId);


    @Transactional
    RecordCourse addArriveData(Long schedulingDetailId, Long studentId, Integer buckleHouse, StatusRecordEnum status, Integer type, Integer courseType);

    @Transactional
    boolean recordAction(RecordCourse recordCourseParam);

    Result tryListenBuckleHouse(RecordCourse recordCourseParam);

    RecordCourse getLeaveData(Integer yearPart,
                              Integer quarterNum,
                              Integer lessonType,
                              Long studentId,
                              Long subjectsId);

    boolean greaterBuckleMoney(RecordCourse recordCourse, RecordCourse recordCourseOld);

    /**
     * 上满15次课的，手动消课
     * @param recordCourseParam
     * @return
     */
    public Result recordActionConsume(RecordCourse recordCourseParam);

    /**
     * 由请假改为到课
     * @param recordCoruseId
     * @return
     */
    @Transactional
    boolean recordCourseChangeArrice(Long recordCoruseId, StatusRecordEnum statusRecordEnum, ReachTypeEnum reachTypeEnum);

    /**
     * 由到课改为请假
     * @param recordCoruseId
     * @return
     */
    public abstract boolean recordCourseChangeLive(Long recordCoruseId);

    public abstract boolean moreRecordeCourse(Long recordCourseId);

    /**
     *获取学生到课状态
     * @param yearPart
     * @param quarterNUm
     * @param studentId
     * @param subjectsId
     * @param lessonNum
     * @return
     */
    public abstract RecordCourse getStudentClassStatus(Integer yearPart,Integer quarterNUm,Long studentId,Long subjectsId,Integer lessonNum);

    public abstract List<RepairLesson> getRepairLesson(String schoolId, String yearPart, String quarterNum, String subjectsId,String teacherStr);

    /**
     * 招生数据
     * @param schoolId
     * @param startDate
     * @param endDate
     * @param subjectsId
     * @param type
     * @return
     */
    public abstract List<RepairLesson> enrollmentData(String schoolId, String startDate, String endDate, String subjectsId, String type,String teacherStr);

    /**
     *
     * @param yearPart
     * @param quarterNum
     * @param studentId
     * @param subjectsId
     * @param lessonType
     * @return
     */
    Integer getLackCount(Integer yearPart, Integer quarterNum, Long schoolId, Long studentId, Long subjectsId, Integer lessonType);

    /**
     * 获取到课数据
     * @param yearPart
     * @param quarterNum
     * @param studentId
     * @param subjectsId
     * @return
     */
    Integer getRecordCountArrive(Integer yearPart, Integer quarterNum, Long studentId,Long subjectsId);

    Long addTemporaryData(FaceGetScheduling faceGetScheduling, Quarter quarter, Long teacherId, Integer signType, String schoolSiteId);

    boolean addTryListenData(FaceGetScheduling faceGetScheduling, Quarter quarter, Long teacherId);

    Integer getUseLeaveCount(Integer yearPart, Integer quarterNum, Long studentId, Long subjectsId, Integer lessonType);

    public abstract Boolean delLeaveRecord(String ids);

    public abstract List<ArrivalRate> arrivalRate(String schoolId, String SubjectsId, Integer YearPart, Integer QuarterNum, String TeacherName, String StartDate, String EndDate, Integer type, String timeStart, String timeEnd, List<Long> baseSchoolIdList, Integer lessonType, String yearClassId, String trackId, String isTeamDetails, String classify, String trackType, String teamId, String name);

    List<ArrivalRate> tardinessRate(String[] schoolIdList, String SubjectsId, Integer YearPart, Integer QuarterNum, String TeacherName, String StartDate, String EndDate, Integer type, String timeStart, String timeEnd, List<Long> baseSchoolIdList, Integer lessonType, String schoolId, String yearCalssIdStr,String trackId,String isTeamDetails,String classify,String trackType,String teamId, String name);

    public abstract IPage<ClassesNum> classesNumList(IPage<ClassesNum> page, String yearPart, String quarterNum, String schoolId, String subjectsId, String startDate, String endDate, String teacherId, String type, String isDescOrAsc, String isFieldToSc);

    public abstract IPage<ClassesNum> classesNumDetails(IPage<ClassesNum> page, String yearPart, String quarterNum, String schoolId, String subjectsId, String startDate, String endDate, String teacherId);

    public abstract Integer getRecordCourseByDate(Long subjectsId, Long studentId);

    public abstract Boolean updateReach(Integer reachType, Long id);


    RecordCourse getOneForSchedulingDetailId(Long schedulingDetailId, Long studentId);

    /**
     * 由请假已扣改为请假未扣
     *
     * @param id
     * @return
     */
    public Boolean updateSendBackLeave(Long id);

    /**
     * 获取最近三个学期最后一次上课记录
     *
     * @param lessonType
     * @param studentId
     * @return
     */
    RecordCourse getRecordCourseByLastThreeQuarter(Integer yearPart, Integer quarterNum, Integer lessonType, Long studentId, String subjectsId);

    Integer getMaxTaskLesson(Integer YearPart, Integer QuarterNum, String SubjectsId, Long courseVersionId, Integer categoryId);

    String getYetLessonNumStr(Integer yearPart,
                              Integer quarterNum,
                              Long subjectsId,
                              Integer lessonType,
                              Long studentId,
                              String dateTimeNow
    );

    void updateIsUpFirst(Integer yearPart, Integer quarterNum);
}
